package MyDaily.dao.user;

/*修改用户密码*/
import java.sql.Connection;
import java.sql.PreparedStatement;

import MyDaily.dao.DBconnection;

public class changeUserpassword {
	// 修改密码
	public static int updatapassword(String name, String password) {
		Connection conn = null;
		PreparedStatement pStat = null;
		try {
			String sql = "update user set password='" + password + "' where name='" + name + "'";
			conn = DBconnection.getConnection();
			pStat = conn.prepareStatement(sql);
			return pStat.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				// 关闭资源
				if (pStat != null) {
					pStat.close();
				}

				if (conn != null) {
					conn.close();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return 0;
	}
}
